From e1232831a58f1b16bdaef783b0e87ca9c749f39a Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 23 Sep 2003 15:56:08 +0000 Subject: [PATCH] Don't run backward past beginning of all-whitespace string. --- gpsbabel/util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gpsbabel/util.c b/gpsbabel/util.c index fb5f624e1..0bd965b81 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -237,6 +237,8 @@ pstrdup(char *src) void rtrim(char *s) { + char *t = s; + if (!s || !*s) { return; } @@ -246,7 +248,7 @@ rtrim(char *s) } s--; - while (isspace (*s)) { + while ((s >= t) && isspace (*s)) { *s = 0; s--; } -- 2.30.2